package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_boot.dto.SysNoticeQueryDTO;
import com.yxw.live_vod_boot.service.SysNoticeService;
import com.yxw.live_vod_boot.vo.SysNoticeInfoVo;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 系统消息管理
 * @author liuxin
 * @date 2023.11.27
 */
@RestController
@Api(value = "系统消息管理", tags = "系统消息管理")
@Slf4j
@RequestMapping("/api/sysNotice")
public class SysNoticeController {

    @Autowired
    private SysNoticeService sysNoticeService;

    @PostMapping("/getNoticesByUserId")
    @ApiOperation("查询个人系统消息列表")
    public BaseResult<PageVO<SysNoticeInfoVo>> getNoticesByUserId(@RequestBody @Valid SysNoticeQueryDTO dto) {
        PageVO<SysNoticeInfoVo> collectionList = sysNoticeService.getNoticesByUserId(dto);
        return ResultHelper.fillWithSuccess(collectionList);
    }


    @PostMapping("/updateNoticeStatus")
    @ApiOperation("消息变更为已读")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "noticeId", value = "消息ID", required = true)
    })
    public BaseResult updateNoticeStatus(@RequestParam Long noticeId) {
         sysNoticeService.updateNoticeStatus(noticeId);
        return BaseResult.doSuccess(null,"操作成功");
    }
}

